package com.hjxr.xmgl.web.controller;

import java.util.List;

import com.hjxr.framework.web.domain.AjaxResult;
import com.hjxr.sysadmin.uitl.poi.ExcelUtil;
import com.hjxr.sysadmin.web.page.TableDataInfo;
import com.hjxr.xmgl.web.domain.ProjectBaseInfo;
import com.hjxr.xmgl.web.service.IProjectBaseInfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hjxr.framework.aspectj.lang.annotation.Log;
import com.hjxr.framework.aspectj.lang.enums.BusinessType;

/**
 * 项目基本信息（由审计局填写)-项目有且只有一个Controller
 *
 * @author hjxr
 * @date 2021-12-02
 */
@RestController
@RequestMapping("/system/info")
public class ProjectBaseInfoController extends BaseController
{
    @Autowired
    private IProjectBaseInfoService projectBaseInfoService;

    /**
     * 查询项目基本信息（由审计局填写)-项目有且只有一个列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectBaseInfo projectBaseInfo)
    {
        startPage();
        List<ProjectBaseInfo> list = projectBaseInfoService.selectProjectBaseInfoList(projectBaseInfo);
        return getDataTable(list);
    }

    /**
     * 导出项目基本信息（由审计局填写)-项目有且只有一个列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "项目基本信息（由审计局填写)-项目有且只有一个", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ProjectBaseInfo projectBaseInfo)
    {
        List<ProjectBaseInfo> list = projectBaseInfoService.selectProjectBaseInfoList(projectBaseInfo);
        ExcelUtil<ProjectBaseInfo> util = new ExcelUtil<ProjectBaseInfo>(ProjectBaseInfo.class);
        return util.exportExcel(list, "info");
    }

    /**
     * 获取项目基本信息（由审计局填写)-项目有且只有一个详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{projectId}")
    public AjaxResult getInfo(@PathVariable("projectId") String projectId)
    {
        return AjaxResult.success(projectBaseInfoService.selectProjectBaseInfoById(projectId));
    }

    /**
     * 新增项目基本信息（由审计局填写)-项目有且只有一个
     */
    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "项目基本信息（由审计局填写)-项目有且只有一个", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectBaseInfo projectBaseInfo)
    {
        return toAjax(projectBaseInfoService.insertProjectBaseInfo(projectBaseInfo));
    }

    /**
     * 修改项目基本信息（由审计局填写)-项目有且只有一个
     */
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "项目基本信息（由审计局填写)-项目有且只有一个", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectBaseInfo projectBaseInfo)
    {
        return toAjax(projectBaseInfoService.updateProjectBaseInfo(projectBaseInfo));
    }

    /**
     * 删除项目基本信息（由审计局填写)-项目有且只有一个
     */
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "项目基本信息（由审计局填写)-项目有且只有一个", businessType = BusinessType.DELETE)
	@DeleteMapping("/{projectIds}")
    public AjaxResult remove(@PathVariable String[] projectIds)
    {
        return toAjax(projectBaseInfoService.deleteProjectBaseInfoByIds(projectIds));
    }

    public AjaxResult remove(String sql,Integer projectId,Integer id)
    {
        return null;
    }
}
